#include <iostream>
#include "oaDesignDB.h"


using namespace oa; 
using namespace std;
//define infinite number used for overlap graph
# define INFINITE 1000000000
class MyInst;
class MyRow;				  
typedef std::vector<MyInst*> InstsVec;

class MyInst {
    public:
    oaInt4 x,y,x1,x2,y1,y2,Originx,Originy;
	oaInst* Instpointer;
	oaPoint Origin;
    int row;
    int errortype;
	int surplus;
//    oaScalarName name;
    oaSimpleName name;
	
	void SetCenterCoord(int X, int Y){
		x1 = x1 + X-x;
		y1 = y1 + Y-y;
		x2 = x2 + X-x;
		y2 = y2 + Y-y;
		Originx = Originx + X-x;
		Originy = Originy + Y-y;
		x = X;
		y = Y;
		//Instpointer->setOrigin( oaPoint(Originx, Originy));
	}
	
	void SetLowerLeftCoord(int X, int Y){
		x2 = x2 + X-x1;
		y2 = y2 + Y-y1;
		x = x + X-x1;
		y = y + Y-y1;
		Originx = Originx+ X-x1;
		Originy = Originy+ Y-y1;
		x1 = X;
		y1 = Y;
		//Instpointer->setOrigin( oaPoint(Originx, Originy) );
	}
	 
		
    void setInst( oaInst* Inst){
		Instpointer=Inst;
        oaBox vioBox;
        Inst->getBBox(vioBox);
        oaPoint vioPoint;
        vioBox.getCenter(vioPoint);
        x = vioPoint.x();
        y = vioPoint.y();
        vioPoint= vioBox.lowerLeft();
        x1=vioPoint.x();
        y1=vioPoint.y();
        vioPoint= vioBox.upperRight();
        x2=vioPoint.x();
        y2=vioPoint.y();
		
		Instpointer->getOrigin(Origin);
		Originx=Origin.x();
		Originy=Origin.y();
//        oaNativeNS ns;
        Inst->getName(name);
        errortype=0;
    }
};

class MyRow {
    public:
    oaInt4 x,y,x1,x2,y1,y2;
    oaRow* Rowpointer;
    int surplusonRow;
    int numInstonRow;
	int numSites;  //num of sites defined by Qirong
//    int row;
//    int errortype;
//    oaScalarName name;
//    oaSimpleName name;

//-------save a pointer to row and extract coordinates------------------
    void setRow( oaRow* Row){
		Rowpointer = Row;
        oaBox vioBox;
        Row->getBBox(vioBox);
        oaPoint vioPoint;
        vioBox.getCenter(vioPoint);
        x = vioPoint.x();
        y = vioPoint.y();
        vioPoint= vioBox.lowerLeft();
        x1=vioPoint.x();
        y1=vioPoint.y();
        vioPoint= vioBox.upperRight();
        x2=vioPoint.x();
        y2=vioPoint.y();
		
		numSites = Row->getNumSites(); //get number of sites by Qirong
		
//        oaNativeNS ns;
//        Row->getName(name);
//        errortype=0;
	numInstonRow=0;
    }
};